mwan3: handle missing interface gracefully
authorEtienne Champetier <[email protected]>
Sun, 3 Aug 2025 01:50:07 +0000 (21:50 -0400)
committerEtienne Champetier <[email protected]>
Sun, 3 Aug 2025 18:24:52 +0000 (14:24 -0400)
`ubus.call(sprintf('network.interface.%s', ifname), 'status', {})`
returns null if the interface `ifname` doesn't exists (yet).

For pppoe interfaces using `option ipv6 auto`, a virtual interface suffixed `_6`
is automatically created once the connection is established,
but until then it doesn't exists.

Fixes: 6423781254b9f3e52c6102fb2cbcd9f99f2445a3 ("mwan3: reimplement rpcd plugin using ucode")
Signed-off-by: Etienne Champetier <[email protected]>
net/mwan3/Makefile
net/mwan3/files/usr/share/rpcd/ucode/mwan3

index 5451063302d106d2434325f86a75a7421fdab5fa..139a33e64fee4994fb81c9dbed05cebacd3bdc93 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=mwan3
 PKG_VERSION:=2.12.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_MAINTAINER:=Florian Eckert <[email protected]>, \
                Aaron Goodman <[email protected]>
 PKG_LICENSE:=GPL-2.0
index b5c2f4a4cbe780f4a4559ea6fac551ffc3a7e889..2e145c72e5c24053c17b80427e82aca1b9c730bd 100644 (file)
@@ -141,7 +141,7 @@ function interfaces_status(request) {
                        'age': get_x_time(uptime, ifname, 'TIME'),
                        'online': get_x_time(uptime, ifname, 'ONLINE'),
                        'offline': get_x_time(uptime, ifname, 'OFFLINE'),
-                       'uptime': netstatus.uptime || 0,
+                       'uptime': netstatus?.uptime || 0,
                        'score': get_int(ifname, 'SCORE'),
                        'lost': get_int(ifname, 'LOST'),
                        'turn': get_int(ifname, 'TURN'),
@@ -149,7 +149,7 @@ function interfaces_status(request) {
                        'enabled': ucibool(intf['enabled']),
                        'running': track_status == 'active',
                        'tracking': track_status,
-                       'up': netstatus.up,
+                       'up': netstatus?.up || false,
                        'track_ip': track_ips,
                };
        });